<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改调课记录')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-apply-add" th:object="${adjustCourse}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">老师姓名：</label>
            <div class="col-sm-8">
                <select name="teacherId" id="teacherId" class="form-control m-b" th:with="type=${@teacher.getTeacherList()}" required>
                    <option th:each="teacher : ${type}" th:text="${teacher.userName}" th:value="${teacher.userId}"  th:field="*{teacherId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">学科：</label>
            <div class="col-sm-8">
                <select name="subject" class="form-control m-b" th:with="type=${@dict.getType('sc_subject_type')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{subject}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">年级：</label>
            <div class="col-sm-8">
                <select class='form-control selectpicker' id='gradeId' name='gradeId' data-th-grade-id="*{gradeId}" required>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">班级名称：</label>
            <div class="col-sm-8">
                <select class='form-control selectpicker' data-live-search="true" id='classId' name='classId' data-th-class-id="*{classId}"  required>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">调课节次：</label>
            <div class="col-sm-8">
                <select name="courseNo" class="form-control m-b" th:with="type=${@dict.getType('sc_course_no')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{courseNo}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">调课开始：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="beginTime" class="form-control" placeholder="请输入调课开始时间" type="text"  th:value="${#dates.format(adjustCourse.beginTime, 'yyyy-MM-dd')}" required>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">调课结束：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="endTime" class="form-control" placeholder="请输入调课结束时间" type="text"  th:value="${#dates.format(adjustCourse.endTime, 'yyyy-MM-dd')}" required>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">调课原因：</label>
            <div class="col-sm-8">
                <textarea name="reason" class="form-control" type="text" required placeholder="请输入调课原因"  th:field="*{reason}"></textarea>
            </div>
        </div>
    </form>

</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:src="@{/js/common/add_grade.js}"></script>
<script type="text/javascript">
        var prefix = ctx + "school/course"
        $("#form-apply-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var className =  $("#classId").find("option:selected").text();
                var gradeName = $("#gradeId").find("option:selected").text();
                var teacherName = $("#teacherId").find("option:selected").text();
                var data = $.param({"className":className, "gradeName":gradeName,"teacherName":teacherName}) + "&" + $("#form-apply-add").serialize();
                $.operate.save(prefix + "/edit", data);
            }
        }

        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd HH:mm:ss",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd HH:mm:ss",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>